package com.fc.test.controller.admin;

import com.fc.test.model.auto.TsysRole;
import com.fc.test.model.auto.TsysUser;
import com.fc.test.model.custom.RoleVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import com.fc.test.common.base.BaseController;
import com.fc.test.common.domain.AjaxResult;
import com.fc.test.model.auto.TAbbRenzheng;
import com.fc.test.model.custom.TableSplitResult;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.model.custom.TitleVo;
import com.fc.test.service.TAbbRenzhengService;
import io.swagger.annotations.Api;

import java.util.List;

@Controller
@RequestMapping("TAbbRenzhengController")
@Api(value = "")
public class TAbbRenzhengController extends BaseController{

	private String prefix = "admin/tAbbRenzheng";
	@Autowired
	private TAbbRenzhengService tAbbRenzhengService;
   //获取说有商家的信息页面
	@GetMapping("view")
	@RequiresPermissions("gen:tAbbRenzheng:view")
    public String view(Model model)
    {
		String str="";
		setTitle(model, new TitleVo("列表", str+"管理", true,"欢迎进入"+str+"页面", true, false));
        return prefix + "/list";
    }
    //获取当前商家的信息页面
	@GetMapping("sjview")
	@RequiresPermissions("gen:tAbbRenzheng:sjview")
	public String sjview(Model model)
	{
		String str="";
		setTitle(model, new TitleVo("列表", str+"管理", true,"欢迎进入"+str+"页面", true, false));
		return prefix + "/sjlist";
	}
	//获取当前商家的信息数据
	@PostMapping("sjlist")
	@RequiresPermissions("gen:tAbbRenzheng:sjlist")
	@ResponseBody
	public Object sjlist(Tablepar tablepar,String searchTxt,String status){
		PageInfo<TAbbRenzheng> page=tAbbRenzhengService.sjlist(tablepar,searchTxt) ;

		TableSplitResult<TAbbRenzheng> result=new TableSplitResult<TAbbRenzheng>(page.getPageNum(), page.getTotal(), page.getList());
		return  result;
	}
   //获取所有商家的信息列表数据
	@PostMapping("list")
	@RequiresPermissions("gen:tAbbRenzheng:list")
	@ResponseBody
	public Object list(Tablepar tablepar,String searchTxt,String status){
		PageInfo<TAbbRenzheng> page=tAbbRenzhengService.list(tablepar,searchTxt,status) ;
		TableSplitResult<TAbbRenzheng> result=new TableSplitResult<TAbbRenzheng>(page.getPageNum(), page.getTotal(), page.getList());
		return  result;
	}

	/**
     * 新增
     */
    @GetMapping("/add")
    public String add(ModelMap modelMap)
    {
        return prefix + "/add";
    }


	@PostMapping("add")
	@RequiresPermissions("gen:tAbbRenzheng:add")
	@ResponseBody
	public AjaxResult add(TAbbRenzheng tAbbRenzheng,Model model){
		int b=tAbbRenzhengService.insertSelective(tAbbRenzheng);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}

	/**
	 * 删除用户
	 * @param ids
	 * @return
	 */
	@PostMapping("remove")
	@RequiresPermissions("gen:tAbbRenzheng:remove")
	@ResponseBody
	public AjaxResult remove(String ids){
		int b=tAbbRenzhengService.deleteByPrimaryKey(ids);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}



	/**
	 * 跳转审核页面
	 * @param id
	 * @param mmap
	 * @return
	 */
	@GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        mmap.put("TAbbRenzheng", tAbbRenzhengService.selectByPrimaryKey(id));

        return prefix + "/edit";
    }

	/**
     * 审核保存
	 */
    @RequiresPermissions("gen:tAbbRenzheng:shenhe")
    @PostMapping("/shenhe")
    @ResponseBody
    public AjaxResult editSave(TAbbRenzheng record)
    {
        return toAjax(tAbbRenzhengService.updateByPrimaryKeySelective(record));

    }

	/**
	 * 跳转新增商家账号页面
	 */
	@GetMapping("/zhadd/{id}")
	public String zhadd(@PathVariable("id") String id,ModelMap modelMap)
	{
		modelMap.put("id", id);
		return prefix + "/zhadd";
	}
	/**
	 * 跳转修改商家账号页面
	 */
	@GetMapping("/zhedit/{id}")
	public String zhedit(@PathVariable("id") String id, ModelMap mmap)
	{
		mmap.put("TAbbRenzheng", tAbbRenzhengService.selectByPrimaryKey(id));
		return prefix + "/zhedit";
	}

/**
	*
	 * 创建商家后台账号
	 * @param id
	 * @param mmap
	 * @return
 */
	@PostMapping("/zhadd")
	@RequiresPermissions("gen:tAbbRenzheng:zhadd")
	@ResponseBody
	public AjaxResult zhadd(TAbbRenzheng record,Model model){
		int b=tAbbRenzhengService.zhadd(record);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}
	/**
	*
	 * 修改商家后台账号
	 * @param id
	 * @param mmap
	 * @return
			 */
	@PostMapping("/zhedit")
	@RequiresPermissions("gen:tAbbRenzheng:zhedit")
	@ResponseBody
	public AjaxResult zhedit(TAbbRenzheng record)
	{
		return toAjax(tAbbRenzhengService.zhedit(record));
	}
	/**
	*
	 * 禁用商家后台账号
	 * @param id
	 * @param mmap
	 * @return
			 */
	@PostMapping("/jyedit")
	@RequiresPermissions("gen:tAbbRenzheng:jyedit")
	@ResponseBody
	public AjaxResult jyedit(TAbbRenzheng record)
	{
		return toAjax(tAbbRenzhengService.jyedit(record));
	}
	/**
	*
	 * 启用用商家后台账号
	 * @param id
	 * @param mmap
	 * @return
			 */
	@PostMapping("/qyedit")
	@RequiresPermissions("gen:tAbbRenzheng:qyedit")
	@ResponseBody
	public AjaxResult qyedit(TAbbRenzheng record)
	{
		return toAjax(tAbbRenzhengService.qyedit(record));
	}

}
